package fr.adfm.paiement.data;

import java.io.InputStream;
import java.util.Properties;

import fr.adfm.proxy.SP.CompteDTO;

public class PaiementConfiguration {
	
	private Long timeoutBanqueMinutes = 30L;
	private Long timeoutPaiementMaxMinutes=40L;
	private Long pollingFrequencySeconds=60L;
	private String urlSite="http://www.adfm.fr";
	private CompteDTO compteEcommerce;
	
	public PaiementConfiguration() {
		load();
	}

	public Long getTimeoutBanqueMinutes() {
		return timeoutBanqueMinutes;
	}
	public void setTimeoutBanqueMinutes(Long timeoutBanqueMinutes) {
		this.timeoutBanqueMinutes = timeoutBanqueMinutes;
	}
	public Long getTimeoutPaiementMaxMinutes() {
		return timeoutPaiementMaxMinutes;
	}
	public void setTimeoutPaiementMaxMinutes(Long timeoutPaiementMaxMinutes) {
		this.timeoutPaiementMaxMinutes = timeoutPaiementMaxMinutes;
	}
	
	public Long getPollingFrequencySeconds() {
		return pollingFrequencySeconds;
	}
	public void setPollingFrequencySeconds(Long pollingFrequencySeconds) {
		this.pollingFrequencySeconds = pollingFrequencySeconds;
	}
	public String getUrlSite() {
		return urlSite;
	}
	public void setUrlSite(String urlSite) {
		this.urlSite = urlSite;
	}
	
	void load() {
		try {
			Properties props = new Properties();
			InputStream in = getClass().getResourceAsStream("/PaiementManagement.properties");
			props.load(in);
			in.close();		
			
			timeoutBanqueMinutes = (long) Integer.parseInt(props.getProperty("timeoutBanqueMinutes"));
			timeoutPaiementMaxMinutes = (long) Integer.parseInt(props.getProperty("timeoutPaiementMaxMinutes"));
			pollingFrequencySeconds = (long) Integer.parseInt(props.getProperty("pollingFrequencySeconds"));
			urlSite =  props.getProperty("urlSite");
			compteEcommerce = new CompteDTO();
			compteEcommerce.setCryptogramme(props.getProperty("numero_de_crypt"));
			compteEcommerce.setNomDeCompte(props.getProperty("nom_de_compte"));
			compteEcommerce.setNumero(props.getProperty("numero_de_compte"));
		}
		catch(Exception ex)
		{
		}
	
		
		
	}

	public CompteDTO getCompteEcommerce() {
		return compteEcommerce;
	}

	public void setCompteEcommerce(CompteDTO compteEcommerce) {
		this.compteEcommerce = compteEcommerce;
	}
}
